﻿@model RightControl.Model.PlatformAuth
@using Platform.DHgate;
@{
    ViewBag.Title = "添加敦煌店铺";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutForm.cshtml";
}

<style type="text/css">
    .layui-form-label {
        width: 100px;
    }

    .layui-input-block {
        width: 300px;
    }
</style>
<div class="admin-main">
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card-header">敦煌平台</div>
                    <label class="layui-form-label"><span class="fRed">*</span>店铺名称:</label>
                    <div class="layui-input-block">
                        <input id="ShopName" id="Icon" lay-vertype="tips" class="layui-input" type="text" placeholder="请自定义店铺名称，方便您多店铺管理" />
                    </div>    
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" id="submitForm">确定</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </div>
        </div>
</div>
<script type="text/javascript">
    layui.use(['form'], function () {
        var form = layui.form,
            $ = layui.$;

        $('#submitForm').on('click', function () {
            var shopName = $('#ShopName').val();
            if (shopName=='') {
                common.msgError("请输入店铺名!");
                return false;
            } else {
                var reg = new RegExp(/^[a-zA-Z0-9_]{1,20}$/);
                if (!reg.test(shopName)) {
                    common.msgError("请输入英数字组合的店铺名!");
                    return false;
                }
            }          

            window.location.href = escape2Html('@DHAPIService.GetAuthUrl()') + '&state=' + encodeURIComponent(shopName);
            @*common.openTop({
                title: '敦煌登录授权', w: '1300px', h: '650px', content: '@DHAPIService.GetAuthUrl()' + encodeURIComponent(shopName)
            });*@
        });

        function escape2Html(str) {
            var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
            return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
        }
    });
</script>


